﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace BYManageInfoSystem
{
    public partial class Frm_HideColumnSet : Form
    {
        Dictionary<string, int> m_dicColumnName2Index = new Dictionary<string, int>();
        private List<string> lstContractTemp = new List<string>();
        List<int> m_lstTemp = new List<int>();

        public Frm_HideColumnSet()
        {
            InitializeComponent();
        }

        public List<int> GetHideColumnIndexList()
        {

            return m_lstTemp;
        }

        public Frm_HideColumnSet(Dictionary<string, int> dicColumnName2Index)
        {
            foreach (string strTemp in dicColumnName2Index.Keys)
            {
                m_dicColumnName2Index.Add(strTemp, dicColumnName2Index[strTemp]);
            }
            InitializeComponent();
        }

        private void Frm_HideColumnSet_Load(object sender, EventArgs e)
        {
            foreach (string strTemp in m_dicColumnName2Index.Keys)
            {
                this.listBoxAllContract.Items.Add(strTemp.ToString());
                //dicContractToBGCKHTTabID.Add(dr["合同编号"].ToString(), Convert.ToInt32(dr["BGCKHTTabID"].ToString(), 10));
            }
        }

        private void buttonGoOne_Click(object sender, EventArgs e)
        {
            lstContractTemp.Clear();
            if (this.listBoxAllContract.SelectedItems.Count >= 0)
            {
                foreach (object o in this.listBoxAllContract.SelectedItems)
                {
                    string strTemp = (string)o;
                    this.listBoxSelected.Items.Add(strTemp);
                    lstContractTemp.Add(strTemp);

                }
                foreach (string o in lstContractTemp)
                {

                    this.listBoxAllContract.Items.Remove(o);
                }
            }
        }

        private void button2GoAll_Click(object sender, EventArgs e)
        {
            int nCount = this.listBoxAllContract.Items.Count;
            for (int i = 0; i < nCount; i++)
            {
                this.listBoxSelected.Items.Add(this.listBoxAllContract.Items[i]);
            }
            for (int i = nCount - 1; i >= 0; i--)
            {
                this.listBoxAllContract.Items.RemoveAt(i);
            }
        }

        private void button3BackOne_Click(object sender, EventArgs e)
        {
            lstContractTemp.Clear();
            if (this.listBoxSelected.SelectedItems.Count >= 0)
            {
                foreach (object o in this.listBoxSelected.SelectedItems)
                {
                    string strTemp = (string)o;
                    this.listBoxAllContract.Items.Add(strTemp);
                    lstContractTemp.Add(strTemp);

                }
                foreach (string o in lstContractTemp)
                {

                    this.listBoxSelected.Items.Remove(o);
                }
            }
        }

        private void button4BackAll_Click(object sender, EventArgs e)
        {
            int nCount = this.listBoxSelected.Items.Count;
            for (int i = 0; i < nCount; i++)
            {
                this.listBoxAllContract.Items.Add(this.listBoxSelected.Items[i]);
            }
            for (int i = nCount - 1; i >= 0; i--)
            {
                this.listBoxSelected.Items.RemoveAt(i);
            }
        }

        private void buttonOk_Click(object sender, EventArgs e)
        {
            m_lstTemp.Clear();
            if (this.listBoxSelected.Items.Count >= 0)
            {
                foreach (object o in this.listBoxSelected.Items)
                {
                    string strTemp = (string)o;
                    m_lstTemp.Add(m_dicColumnName2Index[strTemp]);

                }
            }
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
    }
}
